<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>属性选择器</title>
    <style>
        [class]{
            background: yellow;
        }
        div[class]{
            color: red;
        }
        /* class拥有box1 */
        div.box1{
            font-size: 24px;
        }
        /* class只有box1 */
        div[class=box1]{
            font-style: italic;
        }
        /* class拥有box1 */
         div[class~=box1]{
            border: 1px solid blue;
        }
        input[name=userName]{
            background: yellow;           
        }
        /* 以p开头 */
        p[class^=p]{
            color: greenyellow;
        }
        /* 以1结尾 */
        p[class$="1"]{
            border: 1px solid rgb(218, 32, 141);
        }
        /* 包含p */
        p[class*=p]{
            font-weight: bold;
        }
    </style>
</head>
<body>
    <div class="box1">div-111111111</div>
    <div class="box2">div-2222222222</div>
    <div>div-333333333333</div>
    <div class="box1">div-444444444</div>
    <div class="box1 box3">div-5555555</div>
    <p class="p1">p-111111111</p>
    <p class="p2">p-2222222222</p>
    <p>p-333333333333</p>
    <form action="">
        <fieldset>
            <legend>注册页面</legend>
            用户名: <input type="text" name="userName">
            <br>
            密&emsp;码: <input type="password" name="password">
            <br>
            <button type="submit">登录</button>
        </fieldset>
    </form>
</body>
</html>